/**
 * 中国地图
 */
(function() {
	'use strict';
	require(['orange','echarts'], function(orange,echarts) {
		var w = Math.floor(document.body.clientWidth*0.5)-5;
		$('#china_map_chart').css({'width':w,'height':w*0.74});
		//JSON
	    $.getJSON('resources/json/china.json', function (chinaData) {
	        echarts.registerMap('china', chinaData);
	        var myChart = echarts.init(document.getElementById('china_map_chart'));
	        var data = [
			            {name: '湖南', value:'1150' ,doctor:'2683'},
			            {name: '重庆', value:'819' ,doctor:'4248'},
			            {name: '四川', value:'789' ,doctor:'2674'},
			            {name: '云南', value:'684' ,doctor:'1119'},
			            {name: '广东', value:'663' ,doctor:'1201'},
			            {name: '河南', value:'639' ,doctor:'2025'},
			            {name: '山东', value:'580' ,doctor:'3326'},
			            {name: '吉林', value:'517' ,doctor:'911'},
			            {name: '陕西', value:'510' ,doctor:'921'},
			            {name: '山西', value:'465' ,doctor:'1514'},
			            {name: '贵州', value:'447' ,doctor:'894'},
			            {name: '河北', value:'446' ,doctor:'1868'},
			            {name: '安徽', value:'402' ,doctor:'1186'},
			            {name: '江苏', value:'380' ,doctor:'3151'},
			            {name: '西藏', value:'379' ,doctor:'716'},
			            {name: '广西', value:'375' ,doctor:'1126'},
			            {name: '甘肃', value:'368' ,doctor:'751'},
			            {name: '浙江', value:'365' ,doctor:'1652'},
			            {name: '黑龙江', value:'296' ,doctor:'535'},
			            {name: '海南', value:'292' ,doctor:'263'},
			            {name: '福建', value:'286' ,doctor:'952'},
			            {name: '宁夏', value:'240' ,doctor:'1'},
			            {name: '江西', value:'223' ,doctor:'528'},
			            {name: '北京', value:'222' ,doctor:'1206'},
			            {name: '内蒙古', value:'219' ,doctor:'668'},
			            {name: '湖北', value:'203' ,doctor:'903'},
			            {name: '新疆', value:'202' ,doctor:'537'},
			            {name: '辽宁', value:'186' ,doctor:'847'},
			            {name: '上海', value:'179' ,doctor:'1470'},
			            {name: '天津', value:'157' ,doctor:'1031'},
			            {name: '青海', value:'138' ,doctor:'229'}
			       ];

			       var option = {
			           tooltip : {
			               trigger: 'item',
			               formatter: function(item){
			            	   var itemData = item.data;
			            	   return itemData.name+'<br/>中医馆：'+itemData.value+' (家)<br/>医生数量：'+itemData.doctor+' (个)';
			               }
			           },
			           visualMap: {
				            min: 100,
				            max: 1400,
				            text:['高','低'],
				            realtime: false,
				            calculable: true,
				            inRange: {
				                //color: ['lightskyblue','#209FCC','#115A89','#044D7A'],
				            	color: ['lightskyblue','#4F8DEA','#216BD9','#0551C3'],
				                colorAlpha:0.4,
				                symbolSize:[100,200]
				            },
				            left:'5%',
				            bottom:'5%',
				            textStyle:{
				                color:'#fff'
				            }
				        },
				        series: [{
		                     name: '全国数据',
		                     type: 'map',
		                     mapType: 'china', // 自定义扩展图表类型
		                     zoom:1.2,
		                     roam:true,
		                     itemStyle:{
			                       normal:{
			                    	   label:{show:false},
			                    	   color:'#fff',
			                           borderColor:'rgba(100,149,237,1)',
			                           borderWidth:1.5,
			                           areaStyle:{
			                               color: '#1b1b1b'
			                           }
			                       },
		                     	emphasis:{
		                     		label:{ 
		                     			show:true
		                     		},
		                     		areaColor:'#EEE'
		                     	}
			                   },
			                   label:{
			                	   emphasis:{
			                		   show:true,
			                		   textStyle:{
			                			   fontSize:18,
			                			   color:'#000',
			                			   fontWeight:600
			                		   }
			                	   }
			                   },
		                     data:data
		                }]
			       };                                

	        // 使用刚指定的配置项和数据显示图表。
	        myChart.setOption(option);
	    });   
	});
})();